clear; clc; close all

dimx = 2;
dimy = 3;
dimz = 4;
n = 10000;

y = 10*rand(n,dimy)-5;

coeffx = 10*rand(dimx,dimy) - 5;

x = y*coeffx' + rand(n,dimx);
% x = x + rand(n,dimx) - 0.5;

coeffz = 10*rand(dimz,dimy) - 5;
z = y*coeffz' + rand(n,dimz);
% z = z + rand(n,dimz) - 0.5;

d = [x y z];
d_orig = d;

d(1:n/2,1:dimx) = inf;
d(n/2 + 1:end,dimx+dimy+1:end) = inf;    
d(ceil(rand(round(numel(d)/5),1)*numel(d))) = inf;

d(:,dimx+1:dimx+dimy) = d_orig(:,dimx+1:dimx+dimy);

nMissingPerColumn = zeros(1,size(d,2));
for i = 1:size(d,2),
    nMissingPerColumn(i) = sum(d(:,i) == inf);
end
coeffs = [1 0 0.1 0.2 -3 -2 -4 1.5 10]';
temp = exp(1 + d_orig*coeffs);
Y = round(temp./(temp + 1));
sum(Y)
% return
data = [[1:n]' Y ones(n,1) d];
data_orig = [[1:n]' Y ones(n,1) d_orig];
% data = [zeros(1,size(data,2)); data];
dlmwrite('C:\Users\Mittal\Documents\Work\Code\exclude_from_cv\C\codebase\CCD\Release\testAim2.txt',data,'delimiter',' ');
dlmwrite('C:\Users\Mittal\Documents\Work\Code\exclude_from_cv\C\codebase\CCD\Release\testAim2_orig.txt',data_orig,'delimiter',',');
csv2bbr('C:\Users\Mittal\Documents\Work\Code\exclude_from_cv\C\codebase\CCD\Release\testAim2.txt');
csv2bbr('C:\Users\Mittal\Documents\Work\Code\exclude_from_cv\C\codebase\CCD\Release\testAim2_orig.txt');
replaceinfile('Inf','NULL','C:\Users\Mittal\Documents\Work\Code\exclude_from_cv\C\codebase\CCD\Release\testAim2.txt');
replaceinfile('Inf','NULL','C:\Users\Mittal\Documents\Work\Code\exclude_from_cv\C\codebase\CCD\Release\testAim2_bbr.txt');
